<%--
  Created by IntelliJ IDEA.
  User: 59806
  Date: 2025/10/19
  Time: 19:01
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://library/welcome" prefix="demo" %>
<%@ taglib prefix="tag" uri="http://library/welcome" %>
<html>
<head>
    <title>LoginLibrarySystem</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="utf-8">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/css/common.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/css/index.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/asserts/css/login_list.css">

    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/asserts/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/asserts/js/login.js"></script>
</head>
<body>
<%@ include file="../../asserts/common/header.jsp" %>
<c:if test="${not empty sessionScope.msg}">
    <div class="alert alert-warning">请以管理员身份登录！！！</div>
    <c:remove var="msg" scope="session"/>
</c:if>

<div class="container login-container">
    <div class="login-card">
        <h2 class="login-title">图书管理系统登录</h2>
        <form class="form-horizontal" method="post">
            <div class="form-group">
                <label for="inputUserName" class="col-sm-2 control-label">用户名：</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputUserName" name="userName"
                           placeholder="请输入用户名">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword" class="col-sm-2 control-label">密码：</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="inputPassword" name="password"
                           placeholder="请输入密码">
                </div>
            </div>
            <div class="form-group remember-box">
                <div class="col-sm-offset-2 col-sm-10">
                    <label><input type="checkbox" name="rememberMe" value="on"> 记住我</label>
                </div>
            </div>
            <div class="form-group btn-group">
                <div class="col-sm-offset-2 col-sm-10 text-center">
                    <c:choose>
                        <c:when test="${mode=='user'}">
                            <button type="submit" class="btn btn-success" name="action" value="user"
                                    formaction="${pageContext.request.contextPath}/login"
                                    style="width: 130px;position: relative;left: 142px;">登录
                            </button>
                        </c:when>
                        <c:when test="${mode=='admin'}">
                            <button type="submit" class="btn btn-primary" name="action" value="admin"
                                    formaction="${pageContext.request.contextPath}/admin/login"
                                    style="width: 130px;position: relative;left: 142px;">管理员登录
                            </button>
                        </c:when>
                    </c:choose>
                </div>
            </div>
        </form>
        <div style="text-align:center;">
            <a href="<c:url value='/register'/>" class="regi">没有账号？前去注册</a>
        </div>
        <br>
        <form action="${pageContext.request.contextPath}/back" method="post" class="text-center">
            <button class="btn btn-outline-secondary back-btn" type="submit" name="action" value="back">返回首页
            </button>
        </form>
    </div>

    <c:if test="${not empty param.flag}">
        <c:choose>
            <c:when test="${param.flag eq '0'}">
                <script>alert("密码错误！！！")</script>
            </c:when>
            <c:when test="${param.flag eq '1'}">
                <script>alert("用户不存在！请注册！")</script>
            </c:when>
        </c:choose>
    </c:if>
</div>
<%@ include file="../../asserts/common/footer.jsp" %>
<script src="${pageContext.request.contextPath}/asserts/js/utils/dynamicBG.js"></script>
</body>
</html>
